<?php

namespace app\support;

use support\Response;

class ResponseHelper
{
    /**
     * @param mixed $data
     * @param string $msg
     * @return Response
     */
    public static function successJson(mixed $data = "", string $msg = "ok"): Response
    {
        return json(array(
            "code" => 1,
            "data" => $data,
            "msg" => $msg
        ), JSON_NUMERIC_CHECK);
    }


    /**
     * @param string $msg
     * @return Response
     */
    public static function failJson(string $msg = "fail"): Response
    {
        return json(array(
            "code" => 0,
            "msg" => $msg
        ));
    }
}